package io.jft.doll.ui.roomList.bind

import android.databinding.ObservableField
import com.g.base.ui.recyclerView.item.BaseItem
import io.jft.doll.R
import io.jft.doll.databinding.ItemRoomBinding
import io.jft.doll.room.entity.common.RoomCEntity

/**
 * Created by G on 2017/11/30 0030.
 */
class RoomItemBind(val item: RoomCEntity) : BaseItem<ItemRoomBinding>() {
    override val layoutId: Int = R.layout.item_room
    var clickAble = ObservableField(false)
    val buttonTip = ObservableField("暂停使用")
    val status = ObservableField("维护中")
    val statusIconColor = ObservableField(R.color.colorStatusStop)

    override fun onBind(binding: ItemRoomBinding) {
        when {
            item.status > 1 -> {
                clickAble.set(false)
                buttonTip.set("暂停使用")
                status.set("维护中")
                statusIconColor.set(R.color.colorStatusStop)
            }
            item.isAppointment -> {
                clickAble.set(true)
                buttonTip.set("取消预约")
                status.set("等${item.queued}人")
                statusIconColor.set(R.color.colorStatusQueued)
            }
            item.queued <= 0 -> {
                clickAble.set(true)
                buttonTip.set("开始游戏")
                status.set("空闲中")
                statusIconColor.set(R.color.colorStatusFree)
            }
            else -> {
                clickAble.set(true)
                buttonTip.set("预约游戏")
                status.set("热抓中")
                statusIconColor.set(R.color.colorStatusBusy)
            }
        }
    }

}